home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 1999 August / SGI Freeware 1999 August.iso / dist / fw_xemacs.idb / usr / freeware / lib / xemacs-20.4 / info / xemacs.info-6.z / xemacs.info-6
Encoding:
GNU Info File  |  1998-05-21  |  49.5 KB  |  1,140 lines

  1. This is Info file ../../info/xemacs.info, produced by Makeinfo version
  2. 1.68 from the input file xemacs.texi.
  3.  
  4.    This file documents the XEmacs editor.
  5.  
  6.    Copyright (C) 1985, 1986, 1988 Richard M. Stallman.  Copyright (C)
  7. 1991, 1992, 1993, 1994 Lucid, Inc.  Copyright (C) 1993, 1994 Sun
  8. Microsystems, Inc.  Copyright (C) 1995 Amdahl Corporation.
  9.  
  10.    Permission is granted to make and distribute verbatim copies of this
  11. manual provided the copyright notice and this permission notice are
  12. preserved on all copies.
  13.  
  14.    Permission is granted to copy and distribute modified versions of
  15. this manual under the conditions for verbatim copying, provided also
  16. that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
  17. General Public License" are included exactly as in the original, and
  18. provided that the entire resulting derived work is distributed under the
  19. terms of a permission notice identical to this one.
  20.  
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for modified
  23. versions, except that the sections entitled "The GNU Manifesto",
  24. "Distribution" and "GNU General Public License" may be included in a
  25. translation approved by the author instead of in the original English.
  26.  
  27. 
  28. File: xemacs.info,  Node: Search Case,  Next: Replace,  Prev: Regexps,  Up: Search
  29.  
  30. Searching and Case
  31. ==================
  32.  
  33.    All searches in Emacs normally ignore the case of the text they are
  34. searching through; if you specify searching for `FOO', `Foo' and `foo'
  35. are also considered a match.  Regexps, and in particular character
  36. sets, are included: `[aB]' matches `a' or `A' or `b' or `B'.
  37.  
  38.    If you want a case-sensitive search, set the variable
  39. `case-fold-search' to `nil'.  Then all letters must match exactly,
  40. including case. `case-fold-search' is a per-buffer variable; altering
  41. it affects only the current buffer, but there is a default value which
  42. you can change as well.  *Note Locals::.  You can also use Case
  43. Sensitive Search from the Options menu on your screen.
  44.  
  45. 
  46. File: xemacs.info,  Node: Replace,  Next: Other Repeating Search,  Prev: Search Case,  Up: Search
  47.  
  48. Replacement Commands
  49. ====================
  50.  
  51.    Global search-and-replace operations are not needed as often in
  52. Emacs as they are in other editors, but they are available.  In
  53. addition to the simple `replace-string' command which is like that
  54. found in most editors, there is a `query-replace' command which asks
  55. you, for each occurrence of a pattern, whether to replace it.
  56.  
  57.    The replace commands all replace one string (or regexp) with one
  58. replacement string.  It is possible to perform several replacements in
  59. parallel using the command `expand-region-abbrevs'.  *Note Expanding
  60. Abbrevs::.
  61.  
  62. * Menu:
  63.  
  64. * Unconditional Replace::  Replacing all matches for a string.
  65. * Regexp Replace::         Replacing all matches for a regexp.
  66. * Replacement and Case::   How replacements preserve case of letters.
  67. * Query Replace::          How to use querying.
  68.  
  69. 
  70. File: xemacs.info,  Node: Unconditional Replace,  Next: Regexp Replace,  Prev: Replace,  Up: Replace
  71.  
  72. Unconditional Replacement
  73. -------------------------
  74.  
  75. `M-x replace-string <RET> STRING <RET> NEWSTRING <RET>'
  76.      Replace every occurrence of STRING with NEWSTRING.
  77.  
  78. `M-x replace-regexp <RET> REGEXP <RET> NEWSTRING <RET>'
  79.      Replace every match for REGEXP with NEWSTRING.
  80.  
  81.    To replace every instance of `foo' after point with `bar', use the
  82. command `M-x replace-string' with the two arguments `foo' and `bar'.
  83. Replacement occurs only after point: if you want to cover the whole
  84. buffer you must go to the beginning first.  By default, all occurrences
  85. up to the end of the buffer are replaced.  To limit replacement to part
  86. of the buffer, narrow to that part of the buffer before doing the
  87. replacement (*note Narrowing::.).
  88.  
  89.    When `replace-string' exits, point is left at the last occurrence
  90. replaced.  The value of point when the `replace-string' command was
  91. issued is remembered on the mark ring; `C-u C-<SPC>' moves back there.
  92.  
  93.    A numeric argument restricts replacement to matches that are
  94. surrounded by word boundaries.
  95.  
  96. 
  97. File: xemacs.info,  Node: Regexp Replace,  Next: Replacement and Case,  Prev: Unconditional Replace,  Up: Replace
  98.  
  99. Regexp Replacement
  100. ------------------
  101.  
  102.    `replace-string' replaces exact matches for a single string.  The
  103. similar command `replace-regexp' replaces any match for a specified
  104. pattern.
  105.  
  106.    In `replace-regexp', the NEWSTRING need not be constant.  It can
  107. refer to all or part of what is matched by the REGEXP.  `\&' in
  108. NEWSTRING stands for the entire text being replaced.  `\D' in
  109. NEWSTRING, where D is a digit, stands for whatever matched the D'th
  110. parenthesized grouping in REGEXP.  For example,
  111.  
  112.      M-x replace-regexp <RET> c[ad]+r <RET> \&-safe <RET>
  113.  
  114. would replace (for example) `cadr' with `cadr-safe' and `cddr' with
  115. `cddr-safe'.
  116.  
  117.      M-x replace-regexp <RET> \(c[ad]+r\)-safe <RET> \1 <RET>
  118.  
  119. would perform exactly the opposite replacements.  To include a `\' in
  120. the text to replace with, you must give `\\'.
  121.  
  122. 
  123. File: xemacs.info,  Node: Replacement and Case,  Next: Query Replace,  Prev: Regexp Replace,  Up: Replace
  124.  
  125. Replace Commands and Case
  126. -------------------------
  127.  
  128.    If the arguments to a replace command are in lower case, the command
  129. preserves case when it makes a replacement.  Thus, the following
  130. command:
  131.  
  132.      M-x replace-string <RET> foo <RET> bar <RET>
  133.  
  134. replaces a lower-case `foo' with a lower case `bar', `FOO' with `BAR',
  135. and `Foo' with `Bar'.  If upper-case letters are used in the second
  136. argument, they remain upper-case every time that argument is inserted.
  137. If upper-case letters are used in the first argument, the second
  138. argument is always substituted exactly as given, with no case
  139. conversion.  Likewise, if the variable `case-replace' is set to `nil',
  140. replacement is done without case conversion.  If `case-fold-search' is
  141. set to `nil', case is significant in matching occurrences of `foo' to
  142. replace; also, case conversion of the replacement string is not done.
  143.  
  144. 
  145. File: xemacs.info,  Node: Query Replace,  Prev: Replacement and Case,  Up: Replace
  146.  
  147. Query Replace
  148. -------------
  149.  
  150. `M-% STRING <RET> NEWSTRING <RET>'
  151. `M-x query-replace <RET> STRING <RET> NEWSTRING <RET>'
  152.      Replace some occurrences of STRING with NEWSTRING.
  153.  
  154. `M-x query-replace-regexp <RET> REGEXP <RET> NEWSTRING <RET>'
  155.      Replace some matches for REGEXP with NEWSTRING.
  156.  
  157.    If you want to change only some of the occurrences of `foo' to
  158. `bar', not all of them, you can use `query-replace' instead of `M-%'.
  159. This command finds occurrences of `foo' one by one, displays each
  160. occurrence, and asks you whether to replace it.  A numeric argument to
  161. `query-replace' tells it to consider only occurrences that are bounded
  162. by word-delimiter characters.
  163.  
  164.    Aside from querying, `query-replace' works just like
  165. `replace-string', and `query-replace-regexp' works just like
  166. `replace-regexp'.
  167.  
  168.    The things you can type when you are shown an occurrence of STRING
  169. or a match for REGEXP are:
  170.  
  171. `<SPC>'
  172.      to replace the occurrence with NEWSTRING.  This preserves case,
  173.      just like `replace-string', provided `case-replace' is non-`nil',
  174.      as it normally is.
  175.  
  176. `<DEL>'
  177.      to skip to the next occurrence without replacing this one.
  178.  
  179. `, (Comma)'
  180.      to replace this occurrence and display the result.  You are then
  181.      prompted for another input character.  However, since the
  182.      replacement has already been made, <DEL> and <SPC> are equivalent.
  183.      At this point, you can type `C-r' (see below) to alter the
  184.      replaced text.  To undo the replacement, you can type `C-x u'.
  185.      This exits the `query-replace'.  If you want to do further
  186.      replacement you must use `C-x ESC' to restart (*note
  187.      Repetition::.).
  188.  
  189. `<ESC>'
  190.      to exit without doing any more replacements.
  191.  
  192. `. (Period)'
  193.      to replace this occurrence and then exit.
  194.  
  195. `!'
  196.      to replace all remaining occurrences without asking again.
  197.  
  198. `^'
  199.      to go back to the location of the previous occurrence (or what
  200.      used to be an occurrence), in case you changed it by mistake.
  201.      This works by popping the mark ring.  Only one `^' in a row is
  202.      allowed, because only one previous replacement location is kept
  203.      during `query-replace'.
  204.  
  205. `C-r'
  206.      to enter a recursive editing level, in case the occurrence needs
  207.      to be edited rather than just replaced with NEWSTRING.  When you
  208.      are done, exit the recursive editing level with `C-M-c' and the
  209.      next occurrence will be displayed.  *Note Recursive Edit::.
  210.  
  211. `C-w'
  212.      to delete the occurrence, and then enter a recursive editing level
  213.      as in `C-r'.  Use the recursive edit to insert text to replace the
  214.      deleted occurrence of STRING.  When done, exit the recursive
  215.      editing level with `C-M-c' and the next occurrence will be
  216.      displayed.
  217.  
  218. `C-l'
  219.      to redisplay the screen and then give another answer.
  220.  
  221. `C-h'
  222.      to display a message summarizing these options, then give another
  223.      answer.
  224.  
  225.    If you type any other character, Emacs exits the `query-replace', and
  226. executes the character as a command.  To restart the `query-replace',
  227. use `C-x <ESC>', which repeats the `query-replace' because it used the
  228. minibuffer to read its arguments.  *Note C-x ESC: Repetition.
  229.  
  230. 
  231. File: xemacs.info,  Node: Other Repeating Search,  Prev: Replace,  Up: Search
  232.  
  233. Other Search-and-Loop Commands
  234. ==============================
  235.  
  236.    Here are some other commands that find matches for a regular
  237. expression.  They all operate from point to the end of the buffer.
  238.  
  239. `M-x occur'
  240.      Print each line that follows point and contains a match for the
  241.      specified regexp.  A numeric argument specifies the number of
  242.      context lines to print before and after each matching line; the
  243.      default is none.
  244.  
  245.      The buffer `*Occur*' containing the output serves as a menu for
  246.      finding occurrences in their original context.  Find an occurrence
  247.      as listed in `*Occur*', position point there, and type `C-c C-c';
  248.      this switches to the buffer that was searched and moves point to
  249.      the original of the same occurrence.
  250.  
  251. `M-x list-matching-lines'
  252.      Synonym for `M-x occur'.
  253.  
  254. `M-x count-matches'
  255.      Print the number of matches following point for the specified
  256.      regexp.
  257.  
  258. `M-x delete-non-matching-lines'
  259.      Delete each line that follows point and does not contain a match
  260.      for the specified regexp.
  261.  
  262. `M-x delete-matching-lines'
  263.      Delete each line that follows point and contains a match for the
  264.      specified regexp.
  265.  
  266. 
  267. File: xemacs.info,  Node: Fixit,  Next: Files,  Prev: Search,  Up: Top
  268.  
  269. Commands for Fixing Typos
  270. *************************
  271.  
  272.    This chapter describes commands that are especially useful when you
  273. catch a mistake in your text just after you have made it, or when you
  274. change your mind while composing text on line.
  275.  
  276. * Menu:
  277.  
  278. * Kill Errors:: Commands to kill a batch of recently entered text.
  279. * Transpose::   Exchanging two characters, words, lines, lists...
  280. * Fixing Case:: Correcting case of last word entered.
  281. * Spelling::    Apply spelling checker to a word, or a whole file.
  282.  
  283. 
  284. File: xemacs.info,  Node: Kill Errors,  Next: Transpose,  Prev: Fixit,  Up: Fixit
  285.  
  286. Killing Your Mistakes
  287. =====================
  288.  
  289. `<DEL>'
  290.      Delete last character (`delete-backward-char').
  291.  
  292. `M-<DEL>'
  293.      Kill last word (`backward-kill-word').
  294.  
  295. `C-x <DEL>'
  296.      Kill to beginning of sentence (`backward-kill-sentence').
  297.  
  298.    The <DEL> character (`delete-backward-char') is the most important
  299. correction command.  When used among graphic (self-inserting)
  300. characters, it can be thought of as canceling the last character typed.
  301.  
  302.    When your mistake is longer than a couple of characters, it might be
  303. more convenient to use `M-<DEL>' or `C-x <DEL>'.  `M-<DEL>' kills back
  304. to the start of the last word, and `C-x <DEL>' kills back to the start
  305. of the last sentence.  `C-x <DEL>' is particularly useful when you are
  306. thinking of what to write as you type it, in case you change your mind
  307. about phrasing.  `M-<DEL>' and `C-x <DEL>' save the killed text for
  308. `C-y' and `M-y' to retrieve.  *Note Yanking::.
  309.  
  310.    `M-<DEL>' is often useful even when you have typed only a few
  311. characters wrong, if you know you are confused in your typing and aren't
  312. sure exactly what you typed.  At such a time, you cannot correct with
  313. <DEL> except by looking at the screen to see what you did.  It requires
  314. less thought to kill the whole word and start over.
  315.  
  316. 
  317. File: xemacs.info,  Node: Transpose,  Next: Fixing Case,  Prev: Kill Errors,  Up: Fixit
  318.  
  319. Transposing Text
  320. ================
  321.  
  322. `C-t'
  323.      Transpose two characters (`transpose-chars').
  324.  
  325. `M-t'
  326.      Transpose two words (`transpose-words').
  327.  
  328. `C-M-t'
  329.      Transpose two balanced expressions (`transpose-sexps').
  330.  
  331. `C-x C-t'
  332.      Transpose two lines (`transpose-lines').
  333.  
  334.    The common error of transposing two adjacent characters can be fixed
  335. with the `C-t' command (`transpose-chars').  Normally, `C-t' transposes
  336. the two characters on either side of point.  When given at the end of a
  337. line, `C-t' transposes the last two characters on the line, rather than
  338. transposing the last character of the line with the newline, which
  339. would be useless.  If you catch a transposition error right away, you
  340. can fix it with just `C-t'.  If you catch the error later,  move the
  341. cursor back to between the two transposed characters.  If you
  342. transposed a space with the last character of the word before it, the
  343. word motion commands are a good way of getting there.  Otherwise, a
  344. reverse search (`C-r') is often the best way.  *Note Search::.
  345.  
  346.    `Meta-t' (`transpose-words') transposes the word before point with
  347. the word after point.  It moves point forward over a word, dragging the
  348. word preceding or containing point forward as well.  The punctuation
  349. characters between the words do not move.  For example, `FOO, BAR'
  350. transposes into `BAR, FOO' rather than `BAR FOO,'.
  351.  
  352.    `C-M-t' (`transpose-sexps') is a similar command for transposing two
  353. expressions (*note Lists::.), and `C-x C-t' (`transpose-lines')
  354. exchanges lines.  It works like `M-t' but in determines the division of
  355. the text into syntactic units differently.
  356.  
  357.    A numeric argument to a transpose command serves as a repeat count:
  358. it tells the transpose command to move the character (word, sexp, line)
  359. before or containing point across several other characters (words,
  360. sexps, lines).  For example, `C-u 3 C-t' moves the character before
  361. point forward across three other characters.  This is equivalent to
  362. repeating `C-t' three times.  `C-u - 4 M-t' moves the word before point
  363. backward across four words.  `C-u - C-M-t' would cancel the effect of
  364. plain `C-M-t'.
  365.  
  366.    A numeric argument of zero transposes the character (word, sexp,
  367. line) ending after point with the one ending after the mark (otherwise a
  368. command with a repeat count of zero would do nothing).
  369.  
  370. 
  371. File: xemacs.info,  Node: Fixing Case,  Next: Spelling,  Prev: Transpose,  Up: Fixit
  372.  
  373. Case Conversion
  374. ===============
  375.  
  376. `M-- M-l'
  377.      Convert last word to lower case.  Note that `Meta--' is
  378.      "Meta-minus."
  379.  
  380. `M-- M-u'
  381.      Convert last word to all upper case.
  382.  
  383. `M-- M-c'
  384.      Convert last word to lower case with capital initial.
  385.  
  386.    A  common error is to type words in the wrong case.  Because of this,
  387. the word case-conversion commands `M-l', `M-u', and `M-c' do not move
  388. the cursor when used with a negative argument.  As soon as you see you
  389. have mistyped the last word, you can simply case-convert it and
  390. continue typing.  *Note Case::.
  391.  
  392. 
  393. File: xemacs.info,  Node: Spelling,  Prev: Fixing Case,  Up: Fixit
  394.  
  395. Checking and Correcting Spelling
  396. ================================
  397.  
  398. `M-$'
  399.      Check and correct spelling of word (`spell-word').
  400.  
  401. `M-x spell-buffer'
  402.      Check and correct spelling of each word in the buffer.
  403.  
  404. `M-x spell-region'
  405.      Check and correct spelling of each word in the region.
  406.  
  407. `M-x spell-string'
  408.      Check spelling of specified word.
  409.  
  410.    To check the spelling of the word before point, and optionally
  411. correct it, use the command `M-$' (`spell-word').  This command runs an
  412. inferior process containing the `spell' program to see whether the word
  413. is correct English.  If it is not, it asks you to edit the word (in the
  414. minibuffer) into a corrected spelling, and then performs a
  415. `query-replace' to substitute the corrected spelling for the old one
  416. throughout the buffer.
  417.  
  418.    If you exit the minibuffer without altering the original spelling, it
  419. means you do not want to do anything to that word.  In that case, the
  420. `query-replace' is not done.
  421.  
  422.    `M-x spell-buffer' checks each word in the buffer the same way that
  423. `spell-word' does, doing a `query-replace' for every incorrect word if
  424. appropriate.
  425.  
  426.    `M-x spell-region' is similar to `spell-buffer' but operates only on
  427. the region, not the entire buffer.
  428.  
  429.    `M-x spell-string' reads a string as an argument and checks whether
  430. that is a correctly spelled English word.  It prints a message giving
  431. the answer in the echo area.
  432.  
  433. 
  434. File: xemacs.info,  Node: Files,  Next: Buffers,  Prev: Fixit,  Up: Top
  435.  
  436. File Handling
  437. *************
  438.  
  439.    The basic unit of stored data in Unix is the "file".  To edit a file,
  440. you must tell Emacs to examine the file and prepare a buffer containing
  441. a copy of the file's text.  This is called "visiting" the file.  Editing
  442. commands apply directly to text in the buffer; that is, to the copy
  443. inside Emacs.  Your changes appear in the file itself only when you
  444. "save" the buffer back into the file.
  445.  
  446.    In addition to visiting and saving files, Emacs can delete, copy,
  447. rename, and append to files, and operate on file directories.
  448.  
  449. * Menu:
  450.  
  451. * File Names::       How to type and edit file name arguments.
  452. * Visiting::         Visiting a file prepares Emacs to edit the file.
  453. * Saving::           Saving makes your changes permanent.
  454. * Reverting::        Reverting cancels all the changes not saved.
  455. * Auto Save::        Auto Save periodically protects against loss of data.
  456. * Version Control::  Version control systems (RCS and SCCS).
  457. * ListDir::          Listing the contents of a file directory.
  458. * Comparing Files::  Finding where two files differ.
  459. * Dired::            "Editing" a directory to delete, rename, etc.
  460.                      the files in it.
  461. * Misc File Ops::    Other things you can do on files.
  462.  
  463. 
  464. File: xemacs.info,  Node: File Names,  Next: Visiting,  Prev: Files,  Up: Files
  465.  
  466. File Names
  467. ==========
  468.  
  469.    Most Emacs commands that operate on a file require you to specify the
  470. file name.  (Saving and reverting are exceptions; the buffer knows which
  471. file name to use for them.)  File names are specified in the minibuffer
  472. (*note Minibuffer::.).  "Completion" is available, to make it easier to
  473. specify long file names.  *Note Completion::.
  474.  
  475.    There is always a "default file name" which is used if you enter an
  476. empty argument by typing just <RET>.  Normally the default file name is
  477. the name of the file visited in the current buffer; this makes it easy
  478. to operate on that file with any of the Emacs file commands.
  479.  
  480.    Each buffer has a default directory, normally the same as the
  481. directory of the file visited in that buffer.  When Emacs reads a file
  482. name, the default directory is used if you do not specify a directory.
  483. If you specify a directory in a relative fashion, with a name that does
  484. not start with a slash, it is interpreted with respect to the default
  485. directory.  The default directory of the current buffer is kept in the
  486. variable `default-directory', which has a separate value in every
  487. buffer.  The value of the variable should end with a slash.
  488.  
  489.    For example, if the default file name is `/u/rms/gnu/gnu.tasks' then
  490. the default directory is `/u/rms/gnu/'.  If you type just `foo', which
  491. does not specify a directory, it is short for `/u/rms/gnu/foo'.
  492. `../.login' would stand for `/u/rms/.login'.  `new/foo' would stand for
  493. the filename `/u/rms/gnu/new/foo'.
  494.  
  495.    The variable `default-directory-alist' takes an alist of major modes
  496. and their opinions on `default-directory' as a Lisp expression to
  497. evaluate.  A resulting value of `nil' is ignored in favor of
  498. `default-directory'.
  499.  
  500.    You can create a new directory with the function `make-directory',
  501. which takes as an argument a file name string. The current directory is
  502. displayed in the minibuffer when the function is called; you can delete
  503. the old directory name and supply a new directory name. For example, if
  504. the current directory is `/u/rms/gnu', you can delete `gnu' and type
  505. `oryx' and <RET> to create `/u/rms/oryx'.  Removing a directory is
  506. similar to creating one.  To remove a directory, use
  507. `remove-directory'; it takes one argument, a file name string.
  508.  
  509.    The command `M-x pwd' prints the current buffer's default directory,
  510. and the command `M-x cd' sets it (to a value read using the
  511. minibuffer).  A buffer's default directory changes only when the `cd'
  512. command is used.  A file-visiting buffer's default directory is
  513. initialized to the directory of the file that is visited there.  If a
  514. buffer is created with `C-x b', its default directory is copied from
  515. that of the buffer that was current at the time.
  516.  
  517.    The default directory name actually appears in the minibuffer when
  518. the minibuffer becomes active to read a file name.  This serves two
  519. purposes: it shows you what the default is, so that you can type a
  520. relative file name and know with certainty what it will mean, and it
  521. allows you to edit the default to specify a different directory.  To
  522. inhibit the insertion of the default directory, set the variable
  523. `insert-default-directory' to `nil'.
  524.  
  525.    Note that it is legitimate to type an absolute file name after you
  526. enter the minibuffer, ignoring the presence of the default directory
  527. name.  The final minibuffer contents may look invalid, but that is not
  528. so.  *Note Minibuffer File::.
  529.  
  530.    `$' in a file name is used to substitute environment variables.  For
  531. example, if you have used the shell command `setenv FOO rms/hacks' to
  532. set up an environment variable named `FOO', then you can use
  533. `/u/$FOO/test.c' or `/u/${FOO}/test.c' as an abbreviation for
  534. `/u/rms/hacks/test.c'.  The environment variable name consists of all
  535. the alphanumeric characters after the `$'; alternatively, it may be
  536. enclosed in braces after the `$'.  Note that the `setenv' command
  537. affects Emacs only if done before Emacs is started.
  538.  
  539.    To access a file with `$' in its name, type `$$'.  This pair is
  540. converted to a single `$' at the same time variable substitution is
  541. performed for single `$'.  The Lisp function that performs the
  542. substitution is called `substitute-in-file-name'.  The substitution is
  543. performed only on filenames read as such using the minibuffer.
  544.  
  545. 
  546. File: xemacs.info,  Node: Visiting,  Next: Saving,  Prev: File Names,  Up: Files
  547.  
  548. Visiting Files
  549. ==============
  550.  
  551. `C-x C-f'
  552.      Visit a file (`find-file').
  553.  
  554. `C-x C-v'
  555.      Visit a different file instead of the one visited last
  556.      (`find-alternate-file').
  557.  
  558. `C-x 4 C-f'
  559.      Visit a file, in another window (`find-file-other-window').  Don't
  560.      change this window.
  561.  
  562. `C-x 5 C-f'
  563.      Visit a file, in another frame (`find-file-other-frame').  Don't
  564.      change this window or frame.
  565.  
  566.    "Visiting" a file means copying its contents into an Emacs buffer so
  567. you can edit it.  Emacs creates a new buffer for each file you visit.
  568. We say that the buffer is visiting the file that it was created to
  569. hold.  Emacs constructs the buffer name from the file name by throwing
  570. away the directory and keeping just the file name.  For example, a file
  571. named `/usr/rms/emacs.tex' is displayed in a buffer named `emacs.tex'.
  572. If a buffer with that name exists, a unique name is constructed by
  573. appending `<2>', `<3>',and so on, using the lowest number that makes a
  574. name that is not already in use.
  575.  
  576.    Each window's mode line shows the name of the buffer that is being
  577. displayed in that window, so you can always tell what buffer you are
  578. editing.
  579.  
  580.    The changes you make with Emacs are made in the Emacs buffer.  They
  581. do not take effect in the file that you visit, or any other permanent
  582. place, until you "save" the buffer.  Saving the buffer means that Emacs
  583. writes the current contents of the buffer into its visited file.  *Note
  584. Saving::.
  585.  
  586.    If a buffer contains changes that have not been saved, the buffer is
  587. said to be "modified".  This is important because it implies that some
  588. changes will be lost if the buffer is not saved.  The mode line displays
  589. two stars near the left margin if the buffer is modified.
  590.  
  591.    To visit a file, use the command `C-x C-f' (`find-file').  Follow
  592. the command with the name of the file you wish to visit, terminated by a
  593. <RET>.  If you are using XEmacs under X, you can also use the Open...
  594. command from the File menu bar item.
  595.  
  596.    The file name is read using the minibuffer (*note Minibuffer::.),
  597. with defaulting and completion in the standard manner (*note File
  598. Names::.).  While in the minibuffer, you can abort `C-x C-f' by typing
  599. `C-g'.
  600.  
  601.    `C-x C-f' has completed successfully when text appears on the screen
  602. and a new buffer name appears in the mode line.  If the specified file
  603. does not exist and could not be created or cannot be read, an error
  604. results.  The error message is printed in the echo area, and includes
  605. the name of the file that Emacs was trying to visit.
  606.  
  607.    If you visit a file that is already in Emacs, `C-x C-f' does not make
  608. another copy.  It selects the existing buffer containing that file.
  609. However, before doing so, it checks that the file itself has not changed
  610. since you visited or saved it last.  If the file has changed, Emacs
  611. prints a warning message.  *Note Simultaneous Editing: Interlocking.
  612.  
  613.    You can switch to a specific file called out in the current buffer by
  614. calling the function `find-this-file'. By providing a prefix argument,
  615. this function calls `filename-at-point' and switches to a buffer
  616. visiting the file FILENAME. It creates one if none already exists. You
  617. can use this function to edit the file mentioned in the buffer you are
  618. working in or to test if the file exists. You can do that by using the
  619. minibuffer completion after snatching the all or part of the filename.
  620.  
  621.    If the variable `find-file-use-truenames''s value is non-`nil', a
  622. buffer's visited filename will always be traced back to the real file.
  623. The filename will never be a symbolic link, and there will never be a
  624. symbolic link anywhere in its directory path. In other words, the
  625. `buffer-file-name' and `buffer-file-truename' will be equal.
  626.  
  627.    If the variable `find-file-compare-truenames' value is non-`nil',
  628. the `find-file' command will check the `buffer-file-truename' of all
  629. visited files when deciding whether a given file is already in a
  630. buffer, instead of just `buffer-file-name'.  If you attempt to visit
  631. another file which is a hard-link or symbolic-link to a file that is
  632. already in a buffer, the existing buffer will be found instead of a
  633. newly created one.
  634.  
  635.    If you want to create a file, just visit it.  Emacs prints `(New
  636. File)' in the echo area, but in other respects behaves as if you had
  637. visited an existing empty file.  If you make any changes and save them,
  638. the file is created.
  639.  
  640.    If you visit a nonexistent file unintentionally (because you typed
  641. the wrong file name), use the `C-x C-v' (`find-alternate-file') command
  642. to visit the file you wanted.  `C-x C-v' is similar to `C-x C-f', but
  643. it kills the current buffer (after first offering to save it if it is
  644. modified).  `C-x C-v' is allowed even if the current buffer is not
  645. visiting a file.
  646.  
  647.    If the file you specify is actually a directory, Dired is called on
  648. that directory (*note Dired::.).  To inhibit this, set the variable
  649. `find-file-run-dired' to `nil'; then it is an error to try to visit a
  650. directory.
  651.  
  652.    `C-x 4 f' (`find-file-other-window') is like `C-x C-f' except that
  653. the buffer containing the specified file is selected in another window.
  654. The window that was selected before `C-x 4 f' continues to show the
  655. same buffer it was already showing.  If you use this command when only
  656. one window is being displayed, that window is split in two, with one
  657. window showing the same buffer as before, and the other one showing the
  658. newly requested file.  *Note Windows::.
  659.  
  660.    `C-x 5 C-f' (`find-file-other-frame') is like `C-x C-f' except that
  661. it creates a new frame in which the file is displayed.
  662.  
  663.    Use the function `find-this-file-other-window' to edit a file
  664. mentioned in the buffer you are editing or to test if that file exists.
  665. To do this, use the minibuffer completion after snatching the part or
  666. all of the filename. By providing a prefix argument, the function calls
  667. `filename-at-point' and switches you to a buffer visiting the file
  668. FILENAME in another window. The function creates a buffer if none
  669. already exists. This function is similar to `find-file-other-window'.
  670.  
  671.    There are two hook variables that allow extensions to modify the
  672. operation of visiting files.  Visiting a file that does not exist runs
  673. the functions in the list `find-file-not-found-hooks'; the value of this
  674. variable is expected to be a list of functions which are called one by
  675. one until one of them returns non-`nil'.  Any visiting of a file,
  676. whether extant or not, expects `find-file-hooks' to contain list of
  677. functions and calls them all, one by one.  In both cases the functions
  678. receive no arguments.  Visiting a nonexistent file runs the
  679. `find-file-not-found-hooks' first.
  680.  
  681. 
  682. File: xemacs.info,  Node: Saving,  Next: Reverting,  Prev: Visiting,  Up: Files
  683.  
  684. Saving Files
  685. ============
  686.  
  687.    "Saving" a buffer in Emacs means writing its contents back into the
  688. file that was visited in the buffer.
  689.  
  690. `C-x C-s'
  691.      Save the current buffer in its visited file (`save-buffer').
  692.  
  693. `C-x s'
  694.      Save any or all buffers in their visited files
  695.      (`save-some-buffers').
  696.  
  697. `M-~'
  698.      Forget that the current buffer has been changed (`not-modified').
  699.  
  700. `C-x C-w'
  701.      Save the current buffer in a specified file, and record that file
  702.      as the one visited in the buffer (`write-file').
  703.  
  704. `M-x set-visited-file-name'
  705.      Change file the name under which the current buffer will be saved.
  706.  
  707.    To save a file and make your changes permanent, type `C-x C-s'
  708. (`save-buffer').  After saving is finished, `C-x C-s' prints a message
  709. such as:
  710.  
  711.      Wrote /u/rms/gnu/gnu.tasks
  712.  
  713. If the selected buffer is not modified (no changes have been made in it
  714. since the buffer was created or last saved), Emacs does not save it
  715. because it would have no effect.  Instead, `C-x C-s' prints a message
  716. in the echo area saying:
  717.  
  718.      (No changes need to be saved)
  719.  
  720.    The command `C-x s' (`save-some-buffers') can save any or all
  721. modified buffers.  First it asks, for each modified buffer, whether to
  722. save it.  The questions should be answered with `y' or `n'.  `C-x C-c',
  723. the key that kills Emacs, invokes `save-some-buffers' and therefore
  724. asks the same questions.
  725.  
  726.    If you have changed a buffer and do not want the changes to be saved,
  727. you should take some action to prevent it.  Otherwise, you are liable to
  728. save it by mistake each time you use `save-some-buffers' or a related
  729. command.  One thing you can do is type `M-~' (`not-modified'), which
  730. removes the indication that the buffer is modified.  If you do this,
  731. none of the save commands will believe that the buffer needs to be
  732. saved.  (`~' is often used as a mathematical symbol for `not'; thus
  733. `Meta-~' is `not', metafied.)  You could also use
  734. `set-visited-file-name' (see below) to mark the buffer as visiting a
  735. different file name, not in use for anything important.
  736.  
  737.    You can also undo all the changes made since the file was visited or
  738. saved, by reading the text from the file again.  This is called
  739. "reverting".  *Note Reverting::.  Alternatively, you can undo all the
  740. changes by repeating the undo command `C-x u'; but this only works if
  741. you have not made more changes than the undo mechanism can remember.
  742.  
  743.    `M-x set-visited-file-name' alters the name of the file that the
  744. current buffer is visiting.  It prompts you for the new file name in the
  745. minibuffer.  You can also use `set-visited-file-name' on a buffer that
  746. is not visiting a file.  The buffer's name is changed to correspond to
  747. the file it is now visiting unless the new name is already used by a
  748. different buffer; in that case, the buffer name is not changed.
  749. `set-visited-file-name' does not save the buffer in the newly visited
  750. file; it just alters the records inside Emacs so that it will save the
  751. buffer in that file.  It also marks the buffer as "modified" so that
  752. `C-x C-s' will save.
  753.  
  754.    If you wish to mark a buffer as visiting a different file and save it
  755. right away, use `C-x C-w' (`write-file').  It is precisely equivalent
  756. to `set-visited-file-name' followed by `C-x C-s'.  `C-x C-s' used on a
  757. buffer that is not visiting  a file has the same effect as `C-x C-w';
  758. that is, it reads a file name, marks the buffer as visiting that file,
  759. and saves it there.  The default file name in a buffer that is not
  760. visiting a file is made by combining the buffer name with the buffer's
  761. default directory.
  762.  
  763.    If Emacs is about to save a file and sees that the date of the latest
  764. version on disk does not match what Emacs last read or wrote, Emacs
  765. notifies you of this fact, because it probably indicates a problem
  766. caused by simultaneous editing and requires your immediate attention.
  767. *Note Simultaneous Editing: Interlocking.
  768.  
  769.    If the variable `require-final-newline' is non-`nil', Emacs puts a
  770. newline at the end of any file that doesn't already end in one, every
  771. time a file is saved or written.
  772.  
  773.    Use the hook variable `write-file-hooks' to implement other ways to
  774. write files, and specify things to be done before files are written.
  775. The value of this variable should be a list of Lisp functions.  When a
  776. file is to be written, the functions in the list are called, one by
  777. one, with no arguments.  If one of them returns a non-`nil' value, Emacs
  778. takes this to mean that the file has been written in some suitable
  779. fashion; the rest of the functions are not called, and normal writing is
  780. not done. Use the hook variable `after-save-hook' to list all the
  781. functions to be called after writing out a buffer to a file.
  782.  
  783. * Menu:
  784.  
  785. * Backup::       How Emacs saves the old version of your file.
  786. * Interlocking:: How Emacs protects against simultaneous editing
  787.                   of one file by two users.
  788.  
  789. 
  790. File: xemacs.info,  Node: Backup,  Next: Interlocking,  Prev: Saving,  Up: Saving
  791.  
  792. Backup Files
  793. ------------
  794.  
  795.    Because Unix does not provide version numbers in file names,
  796. rewriting a file in Unix automatically destroys all record of what the
  797. file used to contain.  Thus, saving a file from Emacs throws away the
  798. old contents of the file--or it would, except that Emacs carefully
  799. copies the old contents to another file, called the "backup" file,
  800. before actually saving.  (Make sure that the variable
  801. `make-backup-files' is non-`nil'.  Backup files are not written if this
  802. variable is `nil').
  803.  
  804.    At your option, Emacs can keep either a single backup file or a
  805. series of numbered backup files for each file you edit.
  806.  
  807.    Emacs makes a backup for a file only the first time a file is saved
  808. from one buffer.  No matter how many times you save a file, its backup
  809. file continues to contain the contents from before the file was visited.
  810. Normally this means that the backup file contains the contents from
  811. before the current editing session; however, if you kill the buffer and
  812. then visit the file again, a new backup file is made by the next save.
  813.  
  814. * Menu:
  815.  
  816. * Names: Backup Names.        How backup files are named;
  817.                 Choosing single or numbered backup files.
  818. * Deletion: Backup Deletion.    Emacs deletes excess numbered backups.
  819. * Copying: Backup Copying.    Backups can be made by copying or renaming.
  820.  
  821. 
  822. File: xemacs.info,  Node: Backup Names,  Next: Backup Deletion,  Prev: Backup,  Up: Backup
  823.  
  824. Single or Numbered Backups
  825. ..........................
  826.  
  827.    If you choose to have a single backup file (the default), the backup
  828. file's name is constructed by appending `~' to the file name being
  829. edited; thus, the backup file for `eval.c' is `eval.c~'.
  830.  
  831.    If you choose to have a series of numbered backup files, backup file
  832. names are made by appending `.~', the number, and another `~' to the
  833. original file name.  Thus, the backup files of `eval.c' would be called
  834. `eval.c.~1~', `eval.c.~2~', and so on, through names like
  835. `eval.c.~259~' and beyond.
  836.  
  837.    If protection stops you from writing backup files under the usual
  838. names, the backup file is written as `%backup%~' in your home directory.
  839. Only one such file can exist, so only the most recently made backup is
  840. available.
  841.  
  842.    The choice of single backup or numbered backups is controlled by the
  843. variable `version-control'.  Its possible values are:
  844.  
  845. `t'
  846.      Make numbered backups.
  847.  
  848. `nil'
  849.      Make numbered backups for files that have numbered backups already.
  850.      Otherwise, make single backups.
  851.  
  852. `never'
  853.      Never make numbered backups; always make single backups.
  854.  
  855. `version-control' may be set locally in an individual buffer to control
  856. the making of backups for that buffer's file.  For example, Rmail mode
  857. locally sets `version-control' to `never' to make sure that there is
  858. only one backup for an Rmail file.  *Note Locals::.
  859.  
  860. 
  861. File: xemacs.info,  Node: Backup Deletion,  Next: Backup Copying,  Prev: Backup Names,  Up: Backup
  862.  
  863. Automatic Deletion of Backups
  864. .............................
  865.  
  866.    To prevent unlimited consumption of disk space, Emacs can delete
  867. numbered backup versions automatically.  Generally Emacs keeps the
  868. first few backups and the latest few backups, deleting any in between.
  869. This happens every time a new backup is made.  The two variables that
  870. control the deletion are `kept-old-versions' and `kept-new-versions'.
  871. Their values are, respectively the number of oldest (lowest-numbered)
  872. backups to keep and the number of newest (highest-numbered) ones to
  873. keep, each time a new backup is made.  The values are used just after a
  874. new backup version is made; that newly made backup is included in the
  875. count in `kept-new-versions'.  By default, both variables are 2.
  876.  
  877.    If `trim-versions-without-asking' is non-`nil',  excess middle
  878. versions are deleted without notification.  If it is `nil', the
  879. default, you are asked whether the excess middle versions should really
  880. be deleted.
  881.  
  882.    You can also use Dired's `.' (Period) command to delete old versions.
  883. *Note Dired::.
  884.  
  885. 
  886. File: xemacs.info,  Node: Backup Copying,  Prev: Backup Deletion,  Up: Backup
  887.  
  888. Copying vs. Renaming
  889. ....................
  890.  
  891.    You can make backup files by copying the old file or by renaming it.
  892. This makes a difference when the old file has multiple names.  If you
  893. rename the old file into the backup file, the alternate names become
  894. names for the backup file.  If you copy the old file instead, the
  895. alternate names remain names for the file that you are editing, and the
  896. contents accessed by those names will be the new contents.
  897.  
  898.    How you make a backup file may also affect the file's owner and
  899. group.  If you use copying, they do not change.  If renaming is used,
  900. you become the file's owner, and the file's group becomes the default
  901. (different operating systems have different defaults for the group).
  902.  
  903.    Having the owner change is usually a good idea, because then the
  904. owner is always the person who last edited the file.  Occasionally
  905. there is a file whose owner should not change.  Since most files should
  906. change owners, it is a good idea to use local variable lists to set
  907. `backup-by-copying-when-mismatch' for the special cases where the owner
  908. should not change (*note File Variables::.).
  909.  
  910.    Three variables control the choice of renaming or copying.
  911. Normally, renaming is done.  If the variable `backup-by-copying' is
  912. non-`nil', copying is used.  Otherwise, if the variable
  913. `backup-by-copying-when-linked' is non-`nil', copying is done for files
  914. that have multiple names, but renaming may still be done when the file
  915. being edited has only one name.  If the variable
  916. `backup-by-copying-when-mismatch' is non-`nil', copying is done if
  917. renaming would cause the file's owner or group to change.
  918.  
  919. 
  920. File: xemacs.info,  Node: Interlocking,  Prev: Backup,  Up: Saving
  921.  
  922. Protection Against Simultaneous Editing
  923. ---------------------------------------
  924.  
  925.    Simultaneous editing occurs when two users visit the same file, both
  926. make changes, and both save their changes.  If no one was informed that
  927. this was happening, and you saved first, you would later find that your
  928. changes were lost.  On some systems, Emacs notices immediately when the
  929. second user starts to change a file already being edited, and issues a
  930. warning.  When this is not possible, or if the second user has started
  931. to change the file despite the warning, Emacs checks when the file is
  932. saved, and issues a second warning when a user is about to overwrite a
  933. file containing another user's changes.  If you are the user editing the
  934. file, you can take corrective action at this point and prevent actual
  935. loss of work.
  936.  
  937.    When you make the first modification in an Emacs buffer that is
  938. visiting a file, Emacs records that you have locked the file.  (It does
  939. this by writing another file in a directory reserved for this purpose.)
  940. The lock is removed when you save the changes.  The idea is that the
  941. file is locked whenever the buffer is modified.  If you begin to modify
  942. the buffer while the visited file is locked by someone else, this
  943. constitutes a collision, and Emacs asks you what to do.  It does this
  944. by calling the Lisp function `ask-user-about-lock', which you can
  945. redefine to customize what it does.  The standard definition of this
  946. function asks you a question and accepts three possible answers:
  947.  
  948. `s'
  949.      Steal the lock.  Whoever was already changing the file loses the
  950.      lock, and you get the lock.
  951.  
  952. `p'
  953.      Proceed.  Go ahead and edit the file despite its being locked by
  954.      someone else.
  955.  
  956. `q'
  957.      Quit.  This causes an error (`file-locked') and the modification
  958.      you were trying to make in the buffer does not actually take place.
  959.  
  960.    Note that locking works on the basis of a file name; if a file has
  961. multiple names, Emacs does not realize that the two names are the same
  962. file and cannot prevent two users from editing it simultaneously under
  963. different names.  However, basing locking on names means that Emacs can
  964. interlock the editing of new files that do not really exist until they
  965. are saved.
  966.  
  967.    Some systems are not configured to allow Emacs to make locks.  On
  968. these systems, Emacs cannot detect trouble in advance, but it can still
  969. detect it in time to prevent you from overwriting someone else's
  970. changes.
  971.  
  972.    Every time Emacs saves a buffer, it first checks the
  973. last-modification date of the existing file on disk to see that it has
  974. not changed since the file was last visited or saved.  If the date does
  975. not match, it implies that changes were made in the file in some other
  976. way, and these changes are about to be lost if Emacs actually does
  977. save.  To prevent this, Emacs prints a warning message and asks for
  978. confirmation before saving.  Occasionally you will know why the file
  979. was changed and know that it does not matter; then you can answer `yes'
  980. and proceed.  Otherwise, you should cancel the save with `C-g' and
  981. investigate the situation.
  982.  
  983.    The first thing you should do when notified that simultaneous editing
  984. has already taken place is to list the directory with `C-u C-x C-d'
  985. (*note Directory Listing: ListDir.).  This will show the file's current
  986. author.  You should attempt to contact that person and ask him not to
  987. continue editing.  Often the next step is to save the contents of your
  988. Emacs buffer under a different name, and use `diff' to compare the two
  989. files.
  990.  
  991.    Simultaneous editing checks are also made when you visit a file that
  992. is already visited with `C-x C-f' and when you start to modify a file.
  993. This is not strictly necessary, but it is useful to find out about such
  994. a problem as early as possible, when corrective action takes less work.
  995.  
  996.    Another way to protect your file is to set the read, write, and
  997. executable permissions for the file. Use the function
  998. `set-default-file-modes' to set the UNIX `umask' value to the NMASK
  999. argument. The `umask' value is the default protection mode for new
  1000. files.
  1001.  
  1002. 
  1003. File: xemacs.info,  Node: Reverting,  Next: Auto Save,  Prev: Saving,  Up: Files
  1004.  
  1005. Reverting a Buffer
  1006. ==================
  1007.  
  1008.    If you have made extensive changes to a file and then change your
  1009. mind about them, you can get rid of all changes by reading in the
  1010. previous version of the file.  To do this, use `M-x revert-buffer',
  1011. which operates on the current buffer.  Since reverting a buffer can
  1012. result in very extensive changes, you must confirm it with `yes'.
  1013.  
  1014.    If the current buffer has been auto-saved more recently than it has
  1015. been saved explicitly, `revert-buffer' offers to read the auto save file
  1016. instead of the visited file (*note Auto Save::.).  Emacs asks you about
  1017. the auto-save file before the request for confirmation of the
  1018. `revert-buffer' operation, and demands `y' or `n' as an answer.  If you
  1019. have started to type `yes' for confirmation without realizing that the
  1020. auto-save question was going to be asked, the `y' will answer that
  1021. question, but the `es' will not be valid confirmation.  This gives you
  1022. a chance to cancel the operation with `C-g' and try again with the
  1023. answers you really intend.
  1024.  
  1025.    `revert-buffer' keeps point at the same distance (measured in
  1026. characters) from the beginning of the file.  If the file was edited only
  1027. slightly, you will be at approximately the same piece of text after
  1028. reverting as before.  If you have made more extensive changes, the
  1029. value of point in the old file may bring you to a totally different
  1030. piece of text than your last editing point.
  1031.  
  1032.    A buffer reverted from its visited file is marked "not modified"
  1033. until you make a change.
  1034.  
  1035.    Some kinds of buffers whose contents reflect data bases other than
  1036. files, such as Dired buffers, can also be reverted.  For them,
  1037. reverting means recalculating their contents from the appropriate data.
  1038. Buffers created randomly with `C-x b' cannot be reverted;
  1039. `revert-buffer' reports an error when asked to do so.
  1040.  
  1041. 
  1042. File: xemacs.info,  Node: Auto Save,  Next: Version Control,  Prev: Reverting,  Up: Files
  1043.  
  1044. Auto-Saving: Protection Against Disasters
  1045. =========================================
  1046.  
  1047.    Emacs saves all the visited files from time to time (based on
  1048. counting your keystrokes) without being asked.  This is called
  1049. "auto-saving".  It prevents you from losing more than a limited amount
  1050. of work if the system crashes.
  1051.  
  1052.    When Emacs determines it is time for auto-saving, each buffer is
  1053. considered and is auto-saved if auto-saving is turned on for it and it
  1054. has changed since the last time it was auto-saved.  If any auto-saving
  1055. is done, the message `Auto-saving...' is displayed in the echo area
  1056. until auto-saving is finished.  Errors occurring during auto-saving are
  1057. caught so that they do not interfere with the execution of commands you
  1058. have been typing.
  1059.  
  1060. * Menu:
  1061.  
  1062. * Files: Auto Save Files.
  1063. * Control: Auto Save Control.
  1064. * Recover::        Recovering text from auto-save files.
  1065.  
  1066. 
  1067. File: xemacs.info,  Node: Auto Save Files,  Next: Auto Save Control,  Prev: Auto Save,  Up: Auto Save
  1068.  
  1069. Auto-Save Files
  1070. ---------------
  1071.  
  1072.    Auto-saving does not normally write to the files you visited, because
  1073. it can be undesirable to save a program that is in an inconsistent
  1074. state when you have made only half of a planned change.  Instead,
  1075. auto-saving is done in a different file called the "auto-save file",
  1076. and the visited file is changed only when you save explicitly, for
  1077. example, with `C-x C-s'.
  1078.  
  1079.    Normally, the name of the auto-save file is generated by appending
  1080. `#' to the front and back of the visited file name.  Thus, a buffer
  1081. visiting file `foo.c' would be auto-saved in a file `#foo.c#'.  Most
  1082. buffers that are not visiting files are auto-saved only if you request
  1083. it explicitly; when they are auto-saved, the auto-save file name is
  1084. generated by appending `#%' to the front and `#' to the back of buffer
  1085. name.  For example, the `*mail*' buffer in which you compose messages
  1086. to be sent is auto-saved in a file named `#%*mail*#'.  Names of
  1087. auto-save files are generated this way unless you customize the
  1088. functions `make-auto-save-file-name' and `auto-save-file-name-p' to do
  1089. something different.  The file name to be used for auto-saving a buffer
  1090. is calculated at the time auto-saving is turned on in that buffer.
  1091.  
  1092.    If you want auto-saving to be done in the visited file, set the
  1093. variable `auto-save-visited-file-name' to be non-`nil'.  In this mode,
  1094. there is really no difference between auto-saving and explicit saving.
  1095.  
  1096.    Emacs deletes a buffer's auto-save file when you explicitly save the
  1097. buffer.  To inhibit the deletion, set the variable
  1098. `delete-auto-save-files' to `nil'.  Changing the visited file name with
  1099. `C-x C-w' or `set-visited-file-name' renames any auto-save file to
  1100. correspond to the new visited name.
  1101.  
  1102. 
  1103. File: xemacs.info,  Node: Auto Save Control,  Next: Recover,  Prev: Auto Save Files,  Up: Auto Save
  1104.  
  1105. Controlling Auto-Saving
  1106. -----------------------
  1107.  
  1108.    Each time you visit a file, auto-saving is turned on for that file's
  1109. buffer if the variable `auto-save-default' is non-`nil' (but not in
  1110. batch mode; *note Entering Emacs::.).  The default for this variable is
  1111. `t', so Emacs auto-saves buffers that visit files by default.  You can
  1112. use the command `M-x auto-save-mode' to turn auto-saving for a buffer
  1113. on or off.  Like other minor mode commands, `M-x auto-save-mode' turns
  1114. auto-saving on with a positive argument, off with a zero or negative
  1115. argument; with no argument, it toggles.
  1116.  
  1117.    Emacs performs auto-saving periodically based on counting how many
  1118. characters you have typed since the last time auto-saving happened.  The
  1119. variable `auto-save-interval' specifies the number of characters
  1120. between auto-saves.  By default, it is 300.  Emacs also auto-saves
  1121. whenever you call the function `do-auto-save'.
  1122.  
  1123.    Emacs also does auto-saving whenever it gets a fatal error.  This
  1124. includes killing the Emacs job with a shell command such as `kill
  1125. -emacs', or disconnecting a phone line or network connection.
  1126.  
  1127.    You can set the number of seconds of idle time before an auto-save is
  1128. done. Setting the value of the variable `auto-save-timeout' to zero or
  1129. `nil' will  disable auto-saving due to idleness.
  1130.  
  1131.    The actual amount of idle time between auto-saves is logarithmically
  1132. related to the size of the current buffer.  This variable is the number
  1133. of seconds after which an auto-save will happen when the current buffer
  1134. is 50k or less; the timeout will be 2 1/4 times this in a 200k buffer, 3
  1135. 3/4 times this in a 1000k buffer, and 4 1/2 times this in a 2000k
  1136. buffer.
  1137.  
  1138.    For this variable to have any effect, you must do `(require 'timer)'.
  1139.  
  1140.